<?php
declare(strict_types=1);
namespace app\common\model\mysql;

class User extends BaseModel
{

    /**
     * 根据手机号获取用户信息
     *
     * @param string $phone
     * @return User|array|false|Model|null
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public function getUserByPhone(string $phone)
    {
        if (empty($phone)) return false;

        return $this->where('phone', '=', $phone)->find();
    }

    /**
     * 根据用户名获取用户信息
     *
     * @param string $username
     * @return User|array|false|Model|null
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public function getUserByUsername(string $username)
    {
        if (empty($username)) return false;

        return $this->where('username', $username)->find();
    }
}